-
Notifications
You must be signed in to change notification settings - Fork 252
CLDSRV-750: add Server Access Logs #5980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development/9.2
Are you sure you want to change the base?
CLDSRV-750: add Server Access Logs #5980
Conversation
Hello leif-scality,My role is to assist you with the merge of this Available options
Available commands
Status report is not available. |
Incorrect fix versionThe
Considering where you are trying to merge, I ignored possible hotfix versions and I expected to find:
Please check the |
2e9e717 to
9404507
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files
@@ Coverage Diff @@
## development/9.2 #5980 +/- ##
===================================================
+ Coverage 84.10% 84.28% +0.18%
===================================================
Files 193 194 +1
Lines 12335 12425 +90
===================================================
+ Hits 10374 10473 +99
+ Misses 1961 1952 -9
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
00832f8 to
a63c29f
Compare
ed7705b to
b95e090
Compare
Incorrect fix versionThe
Considering where you are trying to merge, I ignored possible hotfix versions and I expected to find:
Please check the |
67a4483 to
9ecbb31
Compare
6c4b7ec to
5cf2562
Compare
|
@nicolas2bert @leif-scality Is this supposed to land in a patch release on 9.1 ? |
lib/Config.js
Outdated
|
|
||
| function parseServerAccessLogs(config) { | ||
| const res = { | ||
| enabled: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be false by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, let's set it to false by default so that access.log is not created in Artesca.
config.json
Outdated
| "objectPutRetention": true | ||
| }, | ||
| "serverAccessLogs": { | ||
| "enabled": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also make sure the API relies on this toggle and returns Not Implemented if enabled: false?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Incorrect fix versionThe
Considering where you are trying to merge, I ignored possible hotfix versions and I expected to find:
Please check the |
dvasilas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(partial review, but I have some comments that can be addressed)
What about tests?
I think we should have tests that verify that what gets written to server-access.log is what is expected, for every API.
It is ok for me to add tests separately in another PR if you prefer, we just need to create the ticket so that we don't forget.
lib/Config.js
Outdated
| function parseServerAccessLogs(config) { | ||
| const res = { | ||
| enabled: true, | ||
| outputFile: './logs/server-access.log', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| outputFile: './logs/server-access.log', | |
| outputFile: '/logs/server-access.log', |
lib/Config.js
Outdated
|
|
||
| function parseServerAccessLogs(config) { | ||
| const res = { | ||
| enabled: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, let's set it to false by default so that access.log is not created in Artesca.
81eb964 to
940992a
Compare
Incorrect fix versionThe
Considering where you are trying to merge, I ignored possible hotfix versions and I expected to find:
Please check the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in the name of the file, there are 3 s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
lib/utilities/serverAccesssLogger.js
Outdated
| request.headers['cf-connecting-ip']; // Cloudflare | ||
|
|
||
| // x-forwarded-for can contain multiple IPs, take the first one | ||
| if (headerRemoteIP && headerRemoteIP.includes(',')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if there is only 1 IP and there is no , ?
What about something like
if (headerRemoteIP) {
remoteIP = headerRemoteIP.includes(',')
? headerRemoteIP.split(',')[0].trim()
: headerRemoteIP;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lib/api/multipartDelete.js
Outdated
| if (request.serverAccessLogs) { | ||
| // eslint-disable-next-line no-param-reassign | ||
| request.serverAccessLogs.analyticsBytesDeleted = partSizeSum; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (request.serverAccessLogs) { | |
| // eslint-disable-next-line no-param-reassign | |
| request.serverAccessLogs.analyticsBytesDeleted = partSizeSum; | |
| if (request.serverAccessLog) { | |
| // eslint-disable-next-line no-param-reassign | |
| request.serverAccessLog.analyticsBytesDeleted = partSizeSum; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lib/api/objectDelete.js
Outdated
| if (request.serverAccessLogs) { | ||
| // eslint-disable-next-line no-param-reassign | ||
| request.serverAccessLogs.analyticsBytesDeleted = objMD['content-length']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (request.serverAccessLogs) { | |
| // eslint-disable-next-line no-param-reassign | |
| request.serverAccessLogs.analyticsBytesDeleted = objMD['content-length']; | |
| if (request.serverAccessLog) { | |
| // eslint-disable-next-line no-param-reassign | |
| request.serverAccessLog.analyticsBytesDeleted = objMD['content-length']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lib/Config.js
Outdated
|
|
||
| if (config && config.serverAccessLogs) { | ||
| if ('enabled' in config.serverAccessLogs) { | ||
| assert(typeof config.serverAccessLogs.enabled === 'boolean'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| assert(typeof config.serverAccessLogs.enabled === 'boolean'); | |
| assert(typeof config.serverAccessLogs.enabled === 'boolean', 'bad config: serverAccessLogs.enabled not boolean'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| "@azure/storage-blob": "^12.28.0", | ||
| "@hapi/joi": "^17.1.1", | ||
| "arsenal": "git+https://github.com/scality/Arsenal#8.2.37", | ||
| "arsenal": "git+https://github.com/scality/Arsenal#improvement/ARSN-531-export-server-access-log-fields", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reminder to fix before merging.
lib/server.js
Outdated
| res.on('finish', () => { | ||
| // eslint-disable-next-line no-param-reassign | ||
| req.serverAccessLog.endTime = process.hrtime.bigint(); | ||
| logServerAccess(req.serverAccessLog, req, res); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first argument is a bit redundant, you could change the function to logServerAccess(req, res).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
| action: params.analyticsAction || null, | ||
| accountName: params.analyticsAccountName || null, | ||
| accountDisplayName: authInfo ? authInfo.getAccountDisplayName() : null, | ||
| userName: params.analyticsUserName || null, | ||
| clientPort: req.socket.remotePort || null, | ||
| httpMethod: req.method || null, | ||
| bytesDeleted: params.analyticsBytesDeleted || null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if adding the analytics prefix to some fields is useful.
The situation in which it would make sense to have it is if we had a field with the same name and we wanted to distinguish between analytics and server access (analyticsAction and serverAccessAction).
Do you think we can remove it?
lib/utilities/serverAccesssLogger.js
Outdated
| const bytesSent = res.serverAccessLog.bytesSent; | ||
| const authInfo = params.authInfo; | ||
|
|
||
| serverAccessLogger.info('SERVER_ACCESS_LOG', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't use this message; we could send an empty message instead to reduce a bit the size of each log
| serverAccessLogger.info('SERVER_ACCESS_LOG', { | |
| serverAccessLogger.info('', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
lib/metadata/metadataUtils.js
Outdated
| const { bucketName } = params; | ||
| return metadata.getBucket(bucketName, log, (err, bucket) => { | ||
| storeServerAccessLogInfo(params.request, params.authInfo, bucket); | ||
| return metadata.getBucket(bucketName, log, (err, bucket, raftSessionId) => { // Extract raft session id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return metadata.getBucket(bucketName, log, (err, bucket, raftSessionId) => { // Extract raft session id | |
| return metadata.getBucket(bucketName, log, (err, bucket, raftSessionId) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Incorrect fix versionThe
Considering where you are trying to merge, I ignored possible hotfix versions and I expected to find:
Please check the |
940992a to
f85dc8f
Compare
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
|
71fbf80 to
9e2c0de
Compare
9e2c0de to
f5edc5a
Compare
No description provided.